class Solution
{
public:
    int iceBreakingGame(int num, int target)
    {
        int ans = 0;
        for (int i = 2; i <= num; i++)
            ans = (ans + target) % i;

        return ans;
    }
};